package org.lg.service;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import org.lg.entity.Team;
import org.springframework.stereotype.Service;


import java.util.Arrays;
import java.util.List;

//spring 使用 容器获取 bean 调用方法
//dubbo  使用 反射调用方法
@Service("TeamService")
public class TeamServiceImpl implements TeamService {
     public String getAllTeam() {
         String result = null;
         List<Team> teams = Arrays.asList(new Team[]{new Team("0001", "斯图加特"),
                 new Team("0002", "拜仁慕尼黑"),
                 new Team("0003", "国际米兰"),
                 new Team("0004", "摩纳哥")
                 , new Team("0001", "托特纳姆热刺"),
                 new Team("0005", "桑普多利亚"),
         new Team()});
         ObjectMapper objectMapper = new ObjectMapper();
         try {
             result =  objectMapper.writeValueAsString(teams);
         } catch (JsonProcessingException e) {
             e.printStackTrace();
         }
         return result;
     }

    public static void main(String[] args) {
        System.out.println(new TeamServiceImpl().getAllTeam());
    }
}
